import {
  getFormatterPrice,
  computeRate
} from '@const/filter'
// 产品大类
export const PRODUCT_CATEGORY = {
  1: '高值',
  2: '低值',
  3: '试剂',
  4: '设备',
  5: '低值'
}
// 管理分类
export const PRODUCT_MANAGE_CATEGORY = {
  1: 'Ⅰ类',
  2: 'Ⅱ类',
  3: 'Ⅲ类'
}
// 注册地
export const PRODUCT_REGISTER_TYPE = {
  0: '国产',
  1: '港澳台',
  2: '进口'
}

export const formContent = [
  {
    $type: 'input',
    $id: 'operationDoctor',
    label: '手术医生',
    $el: {
      placeholder: '请输入'
    },
    rules: [{
      required: true,
      message: '请输入',
      trigger: 'blur'
    }]
  },
  {
    $type: 'input',
    $id: 'diagnoseWay',
    label: '主要诊断(术式)',
    $el: {
      placeholder: '请输入'
    },
    rules: [{
      required: true,
      message: '请输入',
      trigger: 'blur'
    }]
  },
  {
    $type: 'date-picker',
    $id: 'operationDate',
    label: '手术时间',
    $el: {
      type: 'datetime',
      placeholder: '选择日期',
      valueFormat: 'yyyy-MM-dd HH:mm:ss', // 不添加此属性将获取到一个空对象,如果需要校验在rules中不能加type:date属性否则报错
      prefixIcon: 'el-icon-date',
      pickerOptions: {
        disabledDate: time => {
          return time.getTime() < Date.now() - 8.64e7
        }
      }
    },
    rules: [{
      required: true,
      message: '请选择时间',
      trigger: 'change'
    }]
  },
  {
    $type: 'input',
    $id: 'sickName',
    label: '患者姓名',
    $el: {
      placeholder: '请输入'
    }
  },
  {
    $type: 'input',
    $id: 'sickAge',
    label: '患者年龄',
    $el: {
      placeholder: '请输入'
    }
  },
  {
    $type: 'input',
    $id: 'operationRoom',
    label: '手术间',
    $el: {
      placeholder: '请输入'
    }
  },
  {
    $type: 'select',
    $id: 'sickSex',
    label: '患者性别',
    $el: {
      placeholder: '请选择'
    },
    $options: [
      {
        label: '男',
        value: 0
      },
      {
        label: '女',
        value: 1
      }
    ]
  },
  {
    $type: 'input',
    $id: 'admissionNumber',
    label: '住院号',
    $el: {
      placeholder: '请输入'
    }
  },
  {
    $type: 'input',
    $id: 'illArea',
    label: '病区',
    $el: {
      placeholder: '请输入'
    }
  },
  {
    $type: 'input',
    $id: 'bedNum',
    label: '床号',
    $el: {
      placeholder: '请输入'
    }
  }
]
export const operationListColumns = [{
  prop: 'companyCode',
  label: '配送商产品编码',
  minWidth: 160
},
{
  prop: 'prodNameCn',
  label: '配送商产品名称',
  minWidth: 160
},
{
  prop: 'spec',
  label: '规格型号',
  minWidth: 120,
  showTooltipWhenOverflow: true,
  formatter: row => `${row.spec && row.model ? `${row.spec} ${row.model}` : row.model || row.spec ? `${row.model || row.spec}` : ''}`
},
{
  prop: 'manufacturer',
  label: '生产厂家',
  minWidth: 120,
  showTooltipWhenOverflow: true
},
{
  prop: 'registrationNumber',
  label: '注册证号/备案证号',
  minWidth: 180,
  showTooltipWhenOverflow: true
},
{
  prop: 'manageType',
  label: '管理分类',
  minWidth: 120,
  formatter: row => PRODUCT_MANAGE_CATEGORY[row.manageType]
},
{
  prop: 'price',
  label: '单价',
  minWidth: 120,
  formatter: row => getFormatterPrice(row.price || 0)
},
{
  prop: 'purchaseNum',
  label: '订单数量',
  width: 160
},
{
  prop: 'unit',
  label: '计量单位',
  minWidth: 120
},
{
  prop: 'amount',
  label: '小计金额',
  minWidth: 120,
  formatter: row => getFormatterPrice(computeRate(row.count, row.price) || 0)
},

{
  prop: 'registerArea',
  label: '注册地',
  minWidth: 120,
  formatter: row => PRODUCT_REGISTER_TYPE[row.registerArea]
},
{
  prop: 'bigType',
  label: '产品大类',
  minWidth: 120,
  formatter: row => PRODUCT_CATEGORY[row.bigType]
},
{
  minWidth: 160,
  prop: 'provincePlatCode',
  label: '省平台产品编码',
  showTooltipWhenOverflow: true
},
{
  minWidth: 160,
  prop: 'platCode',
  label: 'M平台产品编码',
  showTooltipWhenOverflow: true
},
{
  width: '60',
  prop: 'action',
  label: '操作',
  fixed: 'right'
}
]
